<%@page import="org.quickbundle.orgauth.rmuser.util.IRmUserConstants"%>
<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="js/h-ui/html5shiv.js"></script>
<script type="text/javascript" src="js/h-ui/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/h-ui/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/h-ui.admin/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/h-ui.admin/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="js/h-ui/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<!--/meta 作为公共模版分离出去-->
<%@ include file="/jsp/include/web/new/global.jsp" %>
<title>添加报表模板 </title>
<%@ taglib uri="/dfhc" prefix="dfhc" %>
</head>
<body>
<article class="page-container">
	<form action="" method="post" class="form form-horizontal" id="form-report" name="form-report">
	    <input id="id" type="hidden">
	    <dfhc:div templateId="h_ui_div_row_cl">
	    <dfhc:title templateId="h_ui_label_title"><dfhc:span templateId="h_ui_not_null_span"></dfhc:span>报表编码：</dfhc:title>	    
	    <dfhc:div templateId="h_ui_div_fromcontrol">	        
			<dfhc:input templateId="h_ui_input" value="" placeholder="请输入唯一的报表编码" id="reportCode" name="reportCode"/>			
		</dfhc:div>	    		 
	    </dfhc:div>
		
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:title templateId="h_ui_label_title"><dfhc:span templateId="h_ui_not_null_span"></dfhc:span>报表xml模板:</dfhc:title>
			<dfhc:div templateId="h_ui_div_fromcontrol">
			    <dfhc:span templateId="h_ui_file" inputtextid="reportTemplateFileName" filectrlid="reportTemplateFile" ></dfhc:span>							
			</dfhc:div>
		</dfhc:div>
		
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:title templateId="h_ui_label_title">描述：</dfhc:title>
			<dfhc:div templateId="h_ui_div_fromcontrol">			    
				<dfhc:textarea templateId="h_ui_textarea" id="remark" name="remark" cols="" rows=""   placeholder="说点什么...最少输入255个字符" maxlength="255" ></dfhc:textarea>				
			</dfhc:div>
		</dfhc:div>
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:div templateId="h_ui_div_pop_up_button">
				<dfhc:button templateId="h_ui_save_button" onclick="javascript:upload();"  />
			</dfhc:div>
		</dfhc:div>
	</form>
</article>

<!--_footer 作为公共模版分离出去-->
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/js/new/js/jquery.min.js"></script>  --%>
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/layer/2.4/layer.js"></script> --%>
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui/H-ui.min.js"></script>--%> 
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/H-ui.admin.js"></script>  --%>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/validate-methods.js"></script> 
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/messages_zh.js"></script>  --%>

<!--请在下方写此页面业务相关的脚本-->
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/js/datepicker/WdatePicker.js"></script>  --%>
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/datatables/1.10.0/jquery.dataTables.min.js"></script>  --%>
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/laypage/1.2/laypage.js"></script> --%>
<script type="text/javascript">
var id = '${id}';
//如果没传id，则获取新id；否则根据ID查询记录
var newId ='';
if(isStrEmpty(id)){
	newId = getNewId("QBEXT_REPORT_DEFINE");
}else{
    fillById(id); 
}
$(function(){	
	$("#form-member-add").validate({
		rules:{
			reportCode:{
				required:true,
				minlength:1,
				maxlength:255
			},			
			uploadfile:{
				required:true,
			}			
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){		
		    var url =rootPath+"/pubController/proxyPostResetApi?url="+getReportRootUrl()+"/reportdefine/addReport";
		    url = url+"&reportCode="+$("#reportCode").val()+"&remark="+encodeURI(encodeURI($("#remark").val()));
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		}
	});
});
function upload(){
	//获取根目录
	var fileRootPath = getFileRootPath();
	 
    var url ='';
    if(isStrEmpty(id)){
    	url = rootPath+"/pubController/proxyPostResetApi?url="+getReportRootUrl()+"/reportdefine/addReport";
    	url = url+"&reportCode="+$("#reportCode").val()+"&remark="+encodeURI(encodeURI($("#remark").val()))+"&rootPath="+fileRootPath+"&id="+newId;
    }else{
    	url = rootPath+"/pubController/proxyPostResetApi?url="+getReportRootUrl()+"/reportdefine/updateReport";
    	url = url+"&reportCode="+$("#reportCode").val()+"&remark="+encodeURI(encodeURI($("#remark").val()))+"&rootPath="+fileRootPath+"&id="+id;    	
    }
	//调用ajax上传文件
	if(uploadFile(url,"reportTemplateFile","")){
	  //如果是新增页面，则获取新id
	  if(isStrEmpty(id)){
	   newId =getNewId("QBEXT_REPORT_DEFINE");
	  }	
	}				

}
//根据id填充界面
function fillById(id){
 var url = getReportRootUrl()+"/reportdefine/"+id;
 $.ajax({
    type:'get',//可选get
    url:getRootPath()+"/pubController/proxyGetResetApi?url="+url,
    dataType:'json',
    async:false , //false为同步
    success:function(data,status){
	  if(data.status=="0"){
   	   	    alert(data.message);
   	   }else{
   		   //填充数据
   		   $("#id").val(data.bean.id);
   		   $("#reportCode").val(data.bean.reportCode);
   		   $("#remark").val(data.bean.remark);
   	   }		
   },
   error:function(xhr,s1,s2){
    	var message = xhr.responseText;
		eval("var json = "+message);
		if($.trim(json.exception).length==0){
			alert('数据异常,请刷新页面重试');
		}else{
			alert(json.exception);
		}

   }
   });
}
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>